#! /usr/bin/python

import pycurl

server = 'http://<APPLICATION-NAME>.appspot.com'
file_path = 'people.csv'

buf = ''
def populate_buffer(data):
  global buf
  buf += data

# Get the one time use upload url
c = pycurl.Curl()
c.setopt(c.URL, '%s/getUploadUrl' % server)
c.setopt(c.WRITEFUNCTION, populate_buffer)
c.perform()

upload_url = buf

# Use the one time use upload url to push your blob
print 'Pushing %s to %s' % (file_path, upload_url)
c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.URL, upload_url)
c.setopt(pycurl.HTTPPOST, [('file', (c.FORM_FILE, file_path))])
c.perform()
